//This script produces Figure 1 in section 1 of the Cambridge Element

//We used Stata/SE 18.0 for Mac (Intel 64-bit), Revision 25 Apr 2023

//Load ESS data
use "ess_snapshot_political.dta", clear

//Drop data not needed
drop if cntry == "AL"
drop if cntry == "GE"
drop if cntry == "ME"
drop if cntry == "MK"
drop if cntry == "RS"
drop if cntry == "RU"
drop if cntry == "UA"
drop if cntry == "XK"

drop if cntry == "RO" //too few observations
drop if cntry == "LU" //too few observations
drop if cntry == "TR" //too few observations

//Create new variable providing full country labels
gen country = ""
replace country = "Austria" if cntry == "AT"
replace country = "Belgium" if cntry == "BE"
replace country = "Bulgaria" if cntry == "BG"
replace country = "Switzerland" if cntry == "CH"
replace country = "Cyprus" if cntry == "CY"
replace country = "Czech Republic" if cntry == "CZ"
replace country = "Germany" if cntry == "DE"
replace country = "Denmark" if cntry == "DK"
replace country = "Estonia" if cntry == "EE"
replace country = "Spain" if cntry == "ES"
replace country = "Finland" if cntry == "FI"
replace country = "France" if cntry == "FR"
replace country = "United Kingdom" if cntry == "GB"
replace country = "Greece" if cntry == "GR"
replace country = "Croatia" if cntry == "HR"
replace country = "Hungary" if cntry == "HU"
replace country = "Ireland" if cntry == "IE"
replace country = "Iceland" if cntry == "IS"
replace country = "Israel" if cntry == "IL"
replace country = "Italy" if cntry == "IT"
replace country = "Lithuania" if cntry == "LT"
replace country = "Latvia" if cntry == "LV"
replace country = "Netherlands" if cntry == "NL"
replace country = "Norway" if cntry == "NO"
replace country = "Poland" if cntry == "PL"
replace country = "Portugal" if cntry == "PT"
replace country = "Sweden" if cntry == "SE"
replace country = "Slovenia" if cntry == "SI"
replace country = "Slovakia" if cntry == "SK"


//Collapse to TSCS level
collapse (mean) trstplt trstprl [aweight = pspwght], by(country essround)
sort country essround

//Create year variable
gen year = .
replace year = 2020 if essround == 10
replace year = 2018 if essround == 9
replace year = 2016 if essround == 8
replace year = 2014 if essround == 7
replace year = 2012 if essround == 6
replace year = 2010 if essround == 5
replace year = 2008 if essround == 4
replace year = 2006 if essround == 3
replace year = 2004 if essround == 2
replace year = 2002 if essround == 1


//Plot trust in politicians over time and save as Figure 1
twoway (connected trstprl year), by(country, note("")) xtitle("Year") ytitle("Trust in politicians") scheme(lean2) subtitle(, size(large))
graph export "Figure1.png", width(2500) replace


